#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 205;

int n, n2;
int a[N], sum[N];
int mn[N][N], mx[N][N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  n2 = n * 2;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) a[i + n] = a[i];
  rep(i, 1, n2) sum[i] = sum[i - 1] + a[i];
  rep(len, 2, n) {
    rep(l, 1, n2 + 1 - len) {
      int r = l + len - 1;
      mn[l][r] = 1e9, mx[l][r] = -1e9;
      rep(i, l, r - 1) {
        mn[l][r] = min(mn[l][r], mn[l][i] + mn[i + 1][r] + sum[r] - sum[l - 1]);
        mx[l][r] = max(mx[l][r], mx[l][i] + mx[i + 1][r] + sum[r] - sum[l - 1]);
      }
    }
  }
  int ans1 = 1e9, ans2 = -1e9;
  rep(i, 1, n - 1) ans1 = min(ans1, mn[i][i + n - 1]),
                   ans2 = max(ans2, mx[i][i + n - 1]);
  cout << ans1 << endl << ans2;
  return 0;
}